import axiosInstance from './axiosInstance.js';

// 获取数据
export const getData = async () => {
  try {
    const response = await axiosInstance.get('/data');
    return response;
  } catch (error) {
    console.error('获取数据失败:', error);
    throw error;
  }
};

// 发送数据
export const postData = async (data: any) => {
  try {
    const response = await axiosInstance.post('/data', data);
    return response;
  } catch (error) {
    console.error('发送数据失败:', error);
    throw error;
  }
};

// 更新数据
export const updateData = async (id: number, data: any) => {
  try {
    const response = await axiosInstance.put(`/data/${id}`, data);
    return response;
  } catch (error) {
    console.error('更新数据失败:', error);
    throw error;
  }
};

// 删除数据
export const deleteData = async (id: number) => {
  try {
    const response = await axiosInstance.delete(`/data/${id}`);
    return response;
  } catch (error) {
    console.error('删除数据失败:', error);
    throw error;
  }
};
